package operation;

import book.Book;
import book.Bookshelf;

import java.util.Scanner;

public class FindOperation implements IOperation{
    public void work(Bookshelf bookshelf) {
        System.out.println("查找图书");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int cur = bookshelf.getUsedSize();
        for (int i = 0; i < cur; i++) {
            Book book = bookshelf.getBook(i);
            if (name.equals(book.getName())) {
                System.out.println("找到了，信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书");
    }
}
